<?php

namespace Mana\Controller;

class GroupController extends CommController
{
    public function index()
    {
        $mangroup = M("mangroup");
        $data = getpages($mangroup, null, 10);
        $this->assign("data", $data);
        $this->display();
    }
    
    public function edit($gid)
    {
        $mangroup = M("mangroup");
        $data=$mangroup->find($gid);
        $this->assign("data", $data);
        $this->display();
    }
    
    public function power($gid)
    {
        $mannode=M("mannode");
        $mangroup = M("mangroup");
        
        $node=$mannode->where("mod_status=1")->select();
        $this->assign("node", $node);
        //
        $data=$mangroup->find($gid);
        $this->assign("val", $data);
        $this->display();
    }
    
    public function powerup($gid)
    {
        $mangroup = M("mangroup");
        
        $post=I("post.val");
        $newval['map_value']=implode(",", $post);
        if ($mangroup->where("map_id=".$gid)->save($newval)) {
            $this->success("更新成功");
        } else {
            $this->success("更新失败");
        }
    }
}
